package com.winderinfo.yikaotianxia.ui.order;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.winderinfo.yikaotianxia.R;
import com.winderinfo.yikaotianxia.ui.home.BanXingBean;

import java.util.List;

public class CommodityAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context context;
    private List<OrderInfo.YkOrderBean.YkGoodsBean> list;

    public CommodityAdapter(Context context, List<OrderInfo.YkOrderBean.YkGoodsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_ordertails, viewGroup, false);
        SelectedViewHolder selectedViewHolder = new SelectedViewHolder(view);
        return selectedViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int i) {
        SelectedViewHolder selectedViewHolder = (SelectedViewHolder) viewHolder;
        selectedViewHolder.ordert_name.setText(list.get(i).getTitle());
        selectedViewHolder.ordert_price.setText("￥ " + list.get(i).getPrice());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class SelectedViewHolder extends RecyclerView.ViewHolder {

        private final TextView ordert_name, ordert_price;


        public SelectedViewHolder(@NonNull View itemView) {
            super(itemView);
            ordert_name = itemView.findViewById(R.id.ordert_name);
            ordert_price = itemView.findViewById(R.id.ordert_price);
        }
    }

}
